/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.jm.financeiro.entity;

import br.jm.financeiro.filter.ConfiguraCampoAnnotation;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Type;

/**
 *
 * @author joao
 */
@Entity
@Table(name = "conta_pagar", catalog = "salao", schema = "public")
public class ContaPagar implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "conta_pagar_id_pagar_seq")
    @SequenceGenerator(name = "conta_pagar_id_pagar_seq", sequenceName = "conta_pagar_id_pagar_seq", initialValue = 1, allocationSize = 1)
    @Column(name = "id_pagar", nullable = false)
    private Integer idPagar;
    @Basic(optional = false)
    @Column(name = "dsc_pagar", nullable = false, length = 40)
    private String dscPagar;
    @Column(name = "num_documento", length = 30)
    private String numDocumento;
    @Basic(optional = false)
    @Column(name = "vlr_pagar", nullable = false, precision = 18, scale = 2)
    private BigDecimal vlrPagar;
    @Type(type = "org.hibernate.type.TextType")
    @Column(name = "dsc_obs")
    private String dscObs;
    @Column(name = "per_juros", precision = 18, scale = 2)
    private BigDecimal perJuros;
    @Column(name = "vlr_desconto", precision = 18, scale = 2)
    private BigDecimal vlrDesconto;
    @Column(name = "vlr_multa", precision = 18, scale = 2)
    private BigDecimal vlrMulta;
    @Column(name = "tip_juros", length = 1)
    private String tipJuros;
    @Basic(optional = false)
    @Column(name = "dat_emissao", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date datEmissao;
    @Size(max = 200)
    @Column(name = "num_os", length = 200, nullable = true)
    private String numOs;
    @JoinColumn(name = "id_fornecedor", referencedColumnName = "id_fornecedor", nullable = false)
    @ManyToOne(optional = false)
    private Fornecedor idFornecedor;
    @JoinColumn(name = "id_custo", referencedColumnName = "id_custo", nullable = false)
    @ManyToOne(optional = false)
    private CentroCusto idCusto;
    @ConfiguraCampoAnnotation(tipo = "String", pesquisa = "idEmpresa.nomEmpresa", campo = "nom_Empresa", nomeTabela = "conta_pagar", nomeTabelJoin = "Empresa")
    @JoinColumn(name = "id_Empresa", referencedColumnName = "id_Empresa", nullable = false)
    @ManyToOne
    private Empresa idEmpresa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPagar")
    @LazyCollection(LazyCollectionOption.FALSE)
    @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    private List<ContaPagarParcela> contaPagarParcelaList;

    public ContaPagar() {
    }

    public ContaPagar(Integer idPagar) {
        this.idPagar = idPagar;
    }

    public ContaPagar(Integer idPagar, String dscPagar, Date datEmissao, BigDecimal vlrPagar) {
        this.idPagar = idPagar;
        this.dscPagar = dscPagar;
        this.datEmissao = datEmissao;
        this.vlrPagar = vlrPagar;
    }

    public Integer getIdPagar() {
        return idPagar;
    }

    public void setIdPagar(Integer idPagar) {
        this.idPagar = idPagar;
    }

    public String getDscPagar() {
        return dscPagar;
    }

    public void setDscPagar(String dscPagar) {
        this.dscPagar = dscPagar;
    }

    public Date getDatEmissao() {
        return datEmissao;
    }

    public void setDatEmissao(Date datEmissao) {
        this.datEmissao = datEmissao;
    }

    public String getNumDocumento() {
        return numDocumento;
    }

    public void setNumDocumento(String numDocumento) {
        this.numDocumento = numDocumento;
    }

    public BigDecimal getVlrPagar() {
        return vlrPagar;
    }

    public void setVlrPagar(BigDecimal vlrPagar) {
        this.vlrPagar = vlrPagar;
    }

    public String getDscObs() {
        return dscObs;
    }

    public void setDscObs(String dscObs) {
        this.dscObs = dscObs;
    }

    public BigDecimal getPerJuros() {
        return perJuros;
    }

    public void setPerJuros(BigDecimal perJuros) {
        this.perJuros = perJuros;
    }

    public BigDecimal getVlrDesconto() {
        return vlrDesconto;
    }

    public void setVlrDesconto(BigDecimal vlrDesconto) {
        this.vlrDesconto = vlrDesconto;
    }

    public BigDecimal getVlrMulta() {
        return vlrMulta;
    }

    public void setVlrMulta(BigDecimal vlrMulta) {
        this.vlrMulta = vlrMulta;
    }

    public String getTipJuros() {
        return tipJuros;
    }

    public void setTipJuros(String tipJuros) {
        this.tipJuros = tipJuros;
    }

    public Fornecedor getIdFornecedor() {
        return idFornecedor;
    }

    public void setIdFornecedor(Fornecedor idFornecedor) {
        this.idFornecedor = idFornecedor;
    }

    public CentroCusto getIdCusto() {
        return idCusto;
    }

    public void setIdCusto(CentroCusto idCusto) {
        this.idCusto = idCusto;
    }

    public List<ContaPagarParcela> getContaPagarParcelaList() {
        return contaPagarParcelaList;
    }

    public void setContaPagarParcelaList(List<ContaPagarParcela> contaPagarParcelaList) {
        this.contaPagarParcelaList = contaPagarParcelaList;
    }

    public String getNumOs() {
        return numOs;
    }

    public void setNumOs(String numOs) {
        this.numOs = numOs;
    }

    public Empresa getIdEmpresa() {
        return idEmpresa;
    }

    public void setIdEmpresa(Empresa idEmpresa) {
        this.idEmpresa = idEmpresa;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPagar != null ? idPagar.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ContaPagar)) {
            return false;
        }
        ContaPagar other = (ContaPagar) object;
        if ((this.idPagar == null && other.idPagar != null) || (this.idPagar != null && !this.idPagar.equals(other.idPagar))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.jm.financeiro.entity.ContaPagar[ idPagar=" + idPagar + " ]";
    }
}
